package com.example.meeting.mapper;

import com.example.meeting.model.domain.ToDo;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface ToDoMapper {

    @Select("select * from todolist where user_id = #{user_id}")
    List<ToDo> getUserTodoList(Integer user_id);

    @Insert("insert into todolist(user_id, todo, finish, ddl) values(#{user_id}, #{todo}, #{finish}, #{ddl})")
    void addTodo(Integer user_id, String todo, Integer finish, Date ddl);

    //获取用户的所有待做 兵根据finish(0 未完成 1 已完成)排序 再根据截至时间在前排序
    @Select("select * from todolist where user_id = #{user_id} order by finish,ddl")
    List<ToDo> selectToDoList(Integer user_id);

    @Delete("delete from todolist where id = #{id}")
    void deleteTodo(Integer id);

    @Update("update todolist set user_id = #{user_id}, todo = #{todo}, finish = #{finish}, ddl = #{ddl} where id = #{id}")
    void editTodo(Integer id, Integer user_id, String todo, Integer finish, Date ddl);

}
